#ifndef IMAGEPROCESSOR_H
#define IMAGEPROCESSOR_H

#include <QImage>
#include <QDebug>
#include <QDateTime>
#include <QMessageBox>
#include <QVector>
#include <fstream>
#include <math.h>
#include <vector>
#include <exception>
#include "imageloader.h"
#include "coccurance.h"
#include "wavelet.h"
#include "test.h"
#include "mytype.h"


using namespace cv;

class ImageProcessor 
{
public:
    ImageProcessor();
    ~ImageProcessor();
    void deleteMem();
    void analyzeRegion(const Mat& v, const QList<SeedNode *>& region, bool runFlag = false);
    void analyzeWaveletRegion(const Mat& v, const QList<SeedNode *>& region, bool runFlag = false);
    void analyzeLBPRegion(const Mat& v, const QList<SeedNode *>& regions, bool runFlag = false);
    void setWavelet(bool checked);
    double** getDataPts() { return dataPts;}
    int getDim() { return dim;}
    QString getOutFile() { return outFile;}

private:
    void waveletTransform(Wavelet *wave, float *data, int *idata);
    void waveletCoccurance(int *idata, double* p);
    void convertToInt(float *coe, int *coe_int);
    void findMinMax(float *data, float &max, float &min, int start_h, int start_w, int endw, int endh);
    void getRegionData(float *dst, unsigned char *src, int widthstep, CvPoint &p);
    void getRegionData(int *dst, unsigned char *src, int widthstep, CvPoint &p);
    void fillPts_Light(Coccurance* co, double* p, int index);
    void outputSummary(const QList<SeedNode *>& loc);
    void outputSummary(const QList<SeedNode *>& loc, vector<vector<double>>& featureSet);
    void allocPts(int n);
    void distCoccurance(int *data, double* pts, Coccurance* cc, int g);

    int height, width;			// Height and width of image being processed
    int dim, nPts;				// Size of feature vector dimension, number of feature vectors
    QString outFile;			// File name of training data
    double** dataPts;			// Actual data points in array
};

#endif // IMAGEPROCESSOR_H
